﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StoryTeller.Domain
{
    public class Chapter : BaseDomain
    {
        public Chapter()
        {
            this.CreationDate = DateTime.Now;
            this.LastUpdate = DateTime.Now;
        }

        public string Title { get; set; }

        public string Description { get; set; }

        public ICollection<Contribution> Contributions { get; set; }

        public string Text
        {
            get
            {
                return string.Concat(Contributions.Select(p => p.Text));
            }
        }

        public override bool Validate()
        {
            ValidationMessages = new List<string>();

            if (string.IsNullOrEmpty(this.Title))
            {
                ValidationMessages.Add(Resources.Validation.ValidationMessages.StoryTitleMessage);
            }

            return ValidationMessages.Count > 0;
        }
    }
}
